﻿using System.Threading;
using System;

namespace WebTranslator {
	public class MasterServer {
		public static void Main() {
			CMSProtocolS Server = new CMSProtocolS();
			Baza.start();
			ChooseIpAddress();
			Server.StartListener();
			new Thread(Server.Listen).Start();
		}

		public static void ChooseIpAddress() {
			string line = null;
			int number = -1, size = StartingApplicationPorts.MyIpAddress.Length;
			while (!int.TryParse(line, out number) || number <= 0 || number > size) {
				Console.WriteLine("Wybierz ip do hostowania usługi: (1 - " + size + ")");
				for (int i = 0; i < size; ++i) {
					Console.WriteLine((i + 1) + ": " + StartingApplicationPorts.MyIpAddress[i]);
				}
				line = Console.ReadLine();
			}
			StartingApplicationPorts.ChosenAddress = StartingApplicationPorts.MyIpAddress[number - 1];
		}
	}
}
